home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / what's new / development kits / mac os / security sdk / includes / urlaccess.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-28  |  12.6 KB  |  361 lines

  1. /*
  2.      File:        URL Access.h
  3.  
  4.      Contains:    URL Access interfaces.
  5.  
  6.      Version:    2.0
  7.  
  8.      Copyright:    (c) 1998-1999 by Apple Computer, Inc., all rights reserved
  9.  
  10.      Bugs?:        Please include the the file and version information (from above) with
  11.                  the problem description.  Developers belonging to one of the Apple
  12.                  developer programs can submit bug reports to:
  13.  
  14.                      devsupport@apple.com
  15.  
  16. */
  17. #ifndef __URLACCESS__
  18. #define __URLACCESS__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __FILES__
  25. #include <Files.h>
  26. #endif
  27.  
  28. #ifndef __CODEFRAGMENTS__
  29. #include <CodeFragments.h>
  30. #endif
  31.  
  32. #ifndef __FILESIGNING__
  33. #include <FileSigning.h>
  34. #endif
  35.  
  36.  
  37. /* Data structures and types */
  38.  
  39.  
  40. #if PRAGMA_ONCE
  41. #pragma once
  42. #endif
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47.  
  48. #if PRAGMA_IMPORT
  49. #pragma import on
  50. #endif
  51.  
  52. #if PRAGMA_STRUCT_ALIGN
  53.     #pragma options align=mac68k
  54. #elif PRAGMA_STRUCT_PACKPUSH
  55.     #pragma pack(push, 2)
  56. #elif PRAGMA_STRUCT_PACK
  57.     #pragma pack(2)
  58. #endif
  59.  
  60. typedef struct OpaqueURLReference*         URLReference;
  61.  
  62. enum {
  63.     kURLReplaceExistingFlag        = 1 << 0,
  64.     kURLBinHexFileFlag            = 1 << 1,                        /* Binhex before uploading if necessary*/
  65.     kURLExpandFileFlag            = 1 << 2,                        /* Use StuffIt engine to expand file if necessary*/
  66.     kURLDisplayProgressFlag        = 1 << 3,
  67.     kURLDisplayAuthFlag            = 1 << 4,                        /* Display auth dialog if guest connection fails*/
  68.     kURLUploadFlag                = 1 << 5,                        /* Do an upload instead of a download*/
  69.     kURLIsDirectoryHintFlag        = 1 << 6,                        /* Hint: the URL is a directory*/
  70.     kURLDoNotTryAnonymousFlag    = 1 << 7,                        /* Don't try to connect anonymously before getting logon info*/
  71.     kURLDirectoryListingFlag    = 1 << 8,                        /* Download the directory listing, not the whole directory*/
  72.     kURLExpandAndVerifyFlag        = 1 << 9,                        /* Expand file and then verify using signature resource*/
  73.     kURLNoAutoRedirectFlag        = 1 << 10,                        /* Do not automatically redirect to new URL*/
  74.     kURLDebinhexOnlyFlag        = 1 << 11,                        /* Do not use Stuffit Expander - just internal debinhex engine*/
  75.     kURLReservedFlag            = 1 << 31                        /* reserved for Apple internal use*/
  76. };
  77.  
  78. typedef UInt32                             URLOpenFlags;
  79. enum {
  80.     kURLNullState                = 0,
  81.     kURLInitiatingState            = 1,
  82.     kURLLookingUpHostState        = 2,
  83.     kURLConnectingState            = 3,
  84.     kURLResourceFoundState        = 4,
  85.     kURLDownloadingState        = 5,
  86.     kURLDataAvailableState        = 0x10 + kURLDownloadingState,
  87.     kURLTransactionCompleteState = 6,
  88.     kURLErrorOccurredState        = 7,
  89.     kURLAbortingState            = 8,
  90.     kURLCompletedState            = 9,
  91.     kURLUploadingState            = 10
  92. };
  93.  
  94. typedef UInt32                             URLState;
  95. enum {
  96.     kURLInitiatedEvent            = kURLInitiatingState,
  97.     kURLResourceFoundEvent        = kURLResourceFoundState,
  98.     kURLDownloadingEvent        = kURLDownloadingState,
  99.     kURLAbortInitiatedEvent        = kURLAbortingState,
  100.     kURLCompletedEvent            = kURLCompletedState,
  101.     kURLErrorOccurredEvent        = kURLErrorOccurredState,
  102.     kURLDataAvailableEvent        = kURLDataAvailableState,
  103.     kURLTransactionCompleteEvent = kURLTransactionCompleteState,
  104.     kURLUploadingEvent            = kURLUploadingState,
  105.     kURLSystemEvent                = 29,
  106.     kURLPercentEvent            = 30,
  107.     kURLPeriodicEvent            = 31,
  108.     kURLPropertyChangedEvent    = 32
  109. };
  110.  
  111. typedef UInt32                             URLEvent;
  112. enum {
  113.     kURLInitiatedEventMask        = 1 << (kURLInitiatedEvent - 1),
  114.     kURLResourceFoundEventMask    = 1 << (kURLResourceFoundEvent - 1),
  115.     kURLDownloadingMask            = 1 << (kURLDownloadingEvent - 1),
  116.     kURLUploadingMask            = 1 << (kURLUploadingEvent - 1),
  117.     kURLAbortInitiatedMask        = 1 << (kURLAbortInitiatedEvent - 1),
  118.     kURLCompletedEventMask        = 1 << (kURLCompletedEvent - 1),
  119.     kURLErrorOccurredEventMask    = 1 << (kURLErrorOccurredEvent - 1),
  120.     kURLDataAvailableEventMask    = 1 << (kURLDataAvailableEvent - 1),
  121.     kURLTransactionCompleteEventMask = 1 << (kURLTransactionCompleteEvent - 1),
  122.     kURLSystemEventMask            = 1 << (kURLSystemEvent - 1),
  123.     kURLPercentEventMask        = 1 << (kURLPercentEvent - 1),
  124.     kURLPeriodicEventMask        = 1 << (kURLPeriodicEvent - 1),
  125.     kURLPropertyChangedEventMask = 1 << (kURLPropertyChangedEvent - 1),
  126.     kURLAllBufferEventsMask        = kURLDataAvailableEventMask + kURLTransactionCompleteEventMask,
  127.     kURLAllNonBufferEventsMask    = kURLInitiatedEventMask + kURLDownloadingMask + kURLUploadingMask + kURLAbortInitiatedMask + kURLCompletedEventMask + kURLErrorOccurredEventMask + kURLPercentEventMask + kURLPeriodicEventMask + kURLPropertyChangedEventMask,
  128.     kURLAllEventsMask            = (long)0xFFFFFFFF
  129. };
  130.  
  131. typedef UInt32                             URLEventMask;
  132.  
  133. struct URLCallbackInfo {
  134.     UInt32                             version;
  135.     URLReference                     urlRef;
  136.     const char *                    property;
  137.     UInt32                             currentSize;
  138.     EventRecord *                    systemEvent;
  139. };
  140. typedef struct URLCallbackInfo            URLCallbackInfo;
  141. static const char* kURLURL                        = "URLString";
  142. static const char* kURLResourceSize                = "URLResourceSize";
  143. static const char* kURLLastModifiedTime            = "URLLastModifiedTime";
  144. static const char* kURLMIMEType                    = "URLMIMEType";
  145. static const char* kURLFileType                    = "URLFileType";
  146. static const char* kURLFileCreator                = "URLFileCreator";
  147. static const char* kURLCharacterSet                = "URLCharacterSet";
  148. static const char* kURLResourceName                = "URLResourceName";
  149. static const char* kURLHost                        = "URLHost";
  150. static const char* kURLAuthType                    = "URLAuthType";
  151. static const char* kURLUserName                    = "URLUserName";
  152. static const char* kURLPassword                    = "URLPassword";
  153. static const char* kURLStatusString                = "URLStatusString";
  154. static const char* kURLIsSecure                    = "URLIsSecure";
  155. static const char* kURLCertificate                = "URLCertificate";
  156. static const char* kURLTotalItems                = "URLTotalItems";
  157. /* http and https properties*/
  158. static const char* kURLHTTPRequestMethod        = "URLHTTPRequestMethod";
  159. static const char* kURLHTTPRequestHeader        = "URLHTTPRequestHeader";
  160. static const char* kURLHTTPRequestBody            = "URLHTTPRequestBody";
  161. static const char* kURLHTTPRespHeader            = "URLHTTPRespHeader";
  162. static const char* kURLHTTPUserAgent            = "URLHTTPUserAgent";
  163. static const char* kURLHTTPRedirectedURL        = "URLHTTPRedirectedURL";
  164. /* authentication type flags*/
  165. enum {
  166.     kUserNameAndPasswordFlag    = 0x00000001
  167. };
  168.  
  169. EXTERN_API( OSStatus )
  170. URLGetURLAccessVersion            (UInt32 *                returnVers);
  171.  
  172. #if TARGET_RT_MAC_CFM
  173. #ifdef __cplusplus
  174.     inline pascal Boolean URLAccessAvailable() { return ((URLGetURLAccessVersion != (void*)kUnresolvedCFragSymbolAddress) ); }
  175. #else
  176.     #define URLAccessAvailable()     ((URLGetURLAccessVersion != (void*)kUnresolvedCFragSymbolAddress) )
  177. #endif
  178. #endif  /* TARGET_RT_MAC_CFM */
  179.  
  180. typedef CALLBACK_API( OSStatus , URLNotifyProcPtr )(void *userContext, URLEvent event, URLCallbackInfo *callbackInfo);
  181. typedef CALLBACK_API( OSStatus , URLSystemEventProcPtr )(void *userContext, EventRecord *event);
  182. typedef STACK_UPP_TYPE(URLNotifyProcPtr)                         URLNotifyUPP;
  183. typedef STACK_UPP_TYPE(URLSystemEventProcPtr)                     URLSystemEventUPP;
  184. #if OPAQUE_UPP_TYPES
  185.     EXTERN_API(URLNotifyUPP)
  186.     NewURLNotifyUPP                   (URLNotifyProcPtr        userRoutine);
  187.  
  188.     EXTERN_API(URLSystemEventUPP)
  189.     NewURLSystemEventUPP           (URLSystemEventProcPtr    userRoutine);
  190.  
  191.     EXTERN_API(void)
  192.     DisposeURLNotifyUPP               (URLNotifyUPP            userUPP);
  193.  
  194.     EXTERN_API(void)
  195.     DisposeURLSystemEventUPP       (URLSystemEventUPP        userUPP);
  196.  
  197.     EXTERN_API(OSStatus)
  198.     InvokeURLNotifyUPP               (void *                    userContext,
  199.                                     URLEvent                event,
  200.                                     URLCallbackInfo *        callbackInfo,
  201.                                     URLNotifyUPP            userUPP);
  202.  
  203.     EXTERN_API(OSStatus)
  204.     InvokeURLSystemEventUPP           (void *                    userContext,
  205.                                     EventRecord *            event,
  206.                                     URLSystemEventUPP        userUPP);
  207.  
  208. #else
  209.     enum { uppURLNotifyProcInfo = 0x00000FF0 };                     /* pascal 4_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  210.     enum { uppURLSystemEventProcInfo = 0x000003F0 };                 /* pascal 4_bytes Func(4_bytes, 4_bytes) */
  211.     #define NewURLNotifyUPP(userRoutine)                             (URLNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppURLNotifyProcInfo, GetCurrentArchitecture())
  212.     #define NewURLSystemEventUPP(userRoutine)                         (URLSystemEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppURLSystemEventProcInfo, GetCurrentArchitecture())
  213.     #define DisposeURLNotifyUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  214.     #define DisposeURLSystemEventUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  215.     #define InvokeURLNotifyUPP(userContext, event, callbackInfo, userUPP)  CALL_THREE_PARAMETER_UPP((userUPP), uppURLNotifyProcInfo, (userContext), (event), (callbackInfo))
  216.     #define InvokeURLSystemEventUPP(userContext, event, userUPP)     CALL_TWO_PARAMETER_UPP((userUPP), uppURLSystemEventProcInfo, (userContext), (event))
  217. #endif
  218. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  219. #define NewURLNotifyProc(userRoutine)                             NewURLNotifyUPP(userRoutine)
  220. #define NewURLSystemEventProc(userRoutine)                         NewURLSystemEventUPP(userRoutine)
  221. #define CallURLNotifyProc(userRoutine, userContext, event, callbackInfo) InvokeURLNotifyUPP(userContext, event, callbackInfo, userRoutine)
  222. #define CallURLSystemEventProc(userRoutine, userContext, event)    InvokeURLSystemEventUPP(userContext, event, userRoutine)
  223. EXTERN_API( OSStatus )
  224. URLSimpleDownload                (const char *            url,
  225.                                  FSSpec *                destination,
  226.                                  Handle                 destinationHandle,
  227.                                  URLOpenFlags             openFlags,
  228.                                  URLSystemEventProcPtr     eventProc,
  229.                                  void *                    userContext);
  230.  
  231. EXTERN_API( OSStatus )
  232. URLDownload                        (URLReference             urlRef,
  233.                                  FSSpec *                destination,
  234.                                  Handle                 destinationHandle,
  235.                                  URLOpenFlags             openFlags,
  236.                                  URLSystemEventProcPtr     eventProc,
  237.                                  void *                    userContext);
  238.  
  239. EXTERN_API( OSStatus )
  240. URLSimpleUpload                    (const char *            url,
  241.                                  const FSSpec *            source,
  242.                                  URLOpenFlags             openFlags,
  243.                                  URLSystemEventProcPtr     eventProc,
  244.                                  void *                    userContext);
  245.  
  246. EXTERN_API( OSStatus )
  247. URLUpload                        (URLReference             urlRef,
  248.                                  const FSSpec *            source,
  249.                                  URLOpenFlags             openFlags,
  250.                                  URLSystemEventProcPtr     eventProc,
  251.                                  void *                    userContext);
  252.  
  253. EXTERN_API( OSStatus )
  254. URLNewReference                    (const char *            url,
  255.                                  URLReference *            urlRef);
  256.  
  257. EXTERN_API( OSStatus )
  258. URLDisposeReference                (URLReference             urlRef);
  259.  
  260. EXTERN_API( OSStatus )
  261. URLOpen                            (URLReference             urlRef,
  262.                                  FSSpec *                fileSpec,
  263.                                  URLOpenFlags             openFlags,
  264.                                  URLNotifyProcPtr         notifyProc,
  265.                                  URLEventMask             eventRegister,
  266.                                  void *                    userContext);
  267.  
  268. EXTERN_API( OSStatus )
  269. URLAbort                        (URLReference             urlRef);
  270.  
  271. EXTERN_API( OSStatus )
  272. URLGetDataAvailable                (URLReference             urlRef,
  273.                                  Size *                    dataSize);
  274.  
  275. EXTERN_API( OSStatus )
  276. URLGetBuffer                    (URLReference             urlRef,
  277.                                  void **                buffer,
  278.                                  Size *                    bufferSize);
  279.  
  280. EXTERN_API( OSStatus )
  281. URLReleaseBuffer                (URLReference             urlRef,
  282.                                  void *                    buffer);
  283.  
  284. EXTERN_API( OSStatus )
  285. URLGetProperty                    (URLReference             urlRef,
  286.                                  const char *            property,
  287.                                  void *                    propertyBuffer,
  288.                                  Size                     bufferSize);
  289.  
  290. EXTERN_API( OSStatus )
  291. URLGetPropertySize                (URLReference             urlRef,
  292.                                  const char *            property,
  293.                                  Size *                    propertySize);
  294.  
  295. EXTERN_API( OSStatus )
  296. URLSetProperty                    (URLReference             urlRef,
  297.                                  const char *            property,
  298.                                  void *                    propertyBuffer,
  299.                                  Size                     bufferSize);
  300.  
  301. EXTERN_API( OSStatus )
  302. URLGetCurrentState                (URLReference             urlRef,
  303.                                  URLState *                state);
  304.  
  305. EXTERN_API( OSStatus )
  306. URLGetError                        (URLReference             urlRef,
  307.                                  OSStatus *                urlError);
  308.  
  309. EXTERN_API( OSStatus )
  310. URLIdle                            (void);
  311.  
  312. EXTERN_API( OSStatus )
  313. URLGetFileInfo                    (StringPtr                 fName,
  314.                                  OSType *                fType,
  315.                                  OSType *                fCreator);
  316.  
  317.  
  318. /* Error Codes */
  319. enum {
  320.     kURLInternetAccessErrorCodeBase = -30770,
  321.     kURLInvalidURLReferenceError = kURLInternetAccessErrorCodeBase - 0,
  322.     kURLProgressAlreadyDisplayedError = kURLInternetAccessErrorCodeBase - 1,
  323.     kURLDestinationExistsError    = kURLInternetAccessErrorCodeBase - 2,
  324.     kURLInvalidURLError            = kURLInternetAccessErrorCodeBase - 3,
  325.     kURLUnsupportedSchemeError    = kURLInternetAccessErrorCodeBase - 4,
  326.     kURLServerBusyError            = kURLInternetAccessErrorCodeBase - 5,
  327.     kURLAuthenticationError        = kURLInternetAccessErrorCodeBase - 6,
  328.     kURLPropertyNotYetKnownError = kURLInternetAccessErrorCodeBase - 7,
  329.     kURLUnknownPropertyError    = kURLInternetAccessErrorCodeBase - 8,
  330.     kURLPropertyBufferTooSmallError = kURLInternetAccessErrorCodeBase - 9,
  331.     kURLUnsettablePropertyError    = kURLInternetAccessErrorCodeBase - 10,
  332.     kURLInvalidCallError        = kURLInternetAccessErrorCodeBase - 11,
  333.     kURLFileEmptyError            = kURLInternetAccessErrorCodeBase - 13,
  334.     kURLExtensionFailureError    = kURLInternetAccessErrorCodeBase - 15,
  335.     kURLInvalidConfigurationError = kURLInternetAccessErrorCodeBase - 16,
  336.     kURLAccessNotAvailableError    = kURLInternetAccessErrorCodeBase - 17,
  337.     kURL68kNotSupportedError    = kURLInternetAccessErrorCodeBase - 18
  338. };
  339.  
  340.  
  341. #if PRAGMA_STRUCT_ALIGN
  342.     #pragma options align=reset
  343. #elif PRAGMA_STRUCT_PACKPUSH
  344.     #pragma pack(pop)
  345. #elif PRAGMA_STRUCT_PACK
  346.     #pragma pack()
  347. #endif
  348.  
  349. #ifdef PRAGMA_IMPORT_OFF
  350. #pragma import off
  351. #elif PRAGMA_IMPORT
  352. #pragma import reset
  353. #endif
  354.  
  355. #ifdef __cplusplus
  356. }
  357. #endif
  358.  
  359. #endif /* __URLACCESS__ */
  360.  
  361.